package com.VitalFit.model.enums;

import com.VitalFit.exception.FitnessPlanException;
import lombok.Getter;

@Getter
public enum FitnessPlanTypeEnum {

    SILVER_PLAN(3,"SILVER_PLAN"),
    GOLD_PLAN(4,"SILVER_PLAN"),
    DIAMOND_PLAN(5,"GOLD_PLAN");

    private final int starRequired;
    private final String planName;


    FitnessPlanTypeEnum(int starRequired, String planName) {
        this.starRequired = starRequired;
        this.planName = planName;
    }

    public static FitnessPlanTypeEnum getFitnessPlanByPlanName(String planName) {
        for (FitnessPlanTypeEnum fitnessPlanTypeEnum : FitnessPlanTypeEnum.values()) {
            if (fitnessPlanTypeEnum.getPlanName().equals(planName)) {
                return fitnessPlanTypeEnum;
            }
        }
        throw new IllegalArgumentException("No matching constant for planName " + planName);
    }

    public static FitnessPlanTypeEnum getFitnessPlanByStarRequired(int starRequired) {
        for (FitnessPlanTypeEnum fitnessPlanTypeEnum : FitnessPlanTypeEnum.values()) {
            if (fitnessPlanTypeEnum.getStarRequired() == starRequired) {
                return fitnessPlanTypeEnum;
            }
        }
        throw new FitnessPlanException("No matching constant for starRequired " + starRequired);
    }
}
